"""
2.元素操作.py
1.send_keys() : 向文本框类的元素输入值 .
2.click()   : 对元素进行点击 ,按键 ,  超连接   ,  checkbox
3.clear()  : 清除 文本框中的值
4.submit() :  按钮 等价于 click .
5.size 属性:   返回元素的尺寸大小
6.text 属性    获取元素的文本信息 ,超连接
        断言:
7.get_attribute("name")    获取元素的某个属性信息.

"""
from selenium import webdriver
from time import  sleep
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
sleep(2)
driver.get("http://www.baidu.com")
sleep(5)
driver.find_element(By.ID,"kw").send_keys("周慧敏")
# driver.find_element(By.NAME,"wd").send_keys("邱淑贞")
# driver.find_element(By.CLASS_NAME,"s_ipt").send_keys("关之琳")
# driver.find_element(By.TAG_NAME,"input").send_keys("李嘉欣") # 不推荐
# driver.find_element(By.XPATH,'//*[@id="kw"]').send_keys("李嘉欣")
# driver.find_element(By.CSS_SELECTOR,"#kw").send_keys("张曼玉")  # 推荐使用 css
# driver.find_element(By.LINK_TEXT,"新闻").click()
print(driver.find_element(By.PARTIAL_LINK_TEXT,"新").text)
driver.find_element(By.PARTIAL_LINK_TEXT,"新").click()
sleep(2)
driver.find_element(By.ID,"kw").clear()
print(driver.find_element(By.ID,"kw").get_attribute("name"))
print(driver.find_element(By.ID,"kw").size)
driver.find_element(By.ID,"su").click()
sleep(5)
driver.quit()